.text
.globl idt, gdt
.globl startup_32
startup_32:
    movl    $0x10, %eax
    mov %ax, %ds
    mov %ax, %es
    mov %ax, %fs
    mov %ax, %gs
    lss stack_start, %esp
    call setup_idt
    call setup_gdt
    movl    $0x10, %eax
    mov %ax, %ds
    mov %ax, %es
    mov %ax, %fs
    mov %ax, %gs
    lss stack_start, %esp
    jmp .

setup_idt:
    lidt    idt_descr
    ret

setup_gdt:
    lgdt    gdt_descr
    ret

.align  4
.word   0
idt_descr:
    .word   256 * 8 - 1
    .long   idt

.align  4
.word   0
gdt_descr:
    .word   256 * 8 - 1
    .long   gdt

.align  8
idt:.fill   256, 8, 0

gdt:.quad   0x0000000000000000
    .quad   0x00c09a0000000fff
    .quad   0x00c0920000000fff
    .quad   0x0000000000000000
    .fill   252, 8, 0
